<template>
  <view class="page-container">
    <!-- 顶部导航栏 -->
    <uni-nav-bar
      :border="false"
      title="冻结抵用券"
      fixed
      left-icon="back"
      @clickLeft="goBack"
    />

    <view class="content">
      <!-- 搜索框 -->
      <view class="search-box">
        <uni-easyinput
          v-model="searchKeyword"
          placeholder="请输入订单编号"
          prefixIcon="search"
          :clearable="true"
        >
          <template #right>
            <view class="search-btn" @click="handleSearch">搜索</view>
          </template>
        </uni-easyinput>
      </view>

      <!-- 冻结抵用券列表 -->
      <view class="frozen-list">
        <view
          v-for="(item, index) in frozenList"
          :key="index"
          class="frozen-item"
        >
          <view class="item-header">
            <view class="order-info">
              <text class="order-label">订单编号：</text>
              <text class="order-number">{{ item.orderNumber }}</text>
            </view>
            <view class="frozen-amount">{{ item.amount }}</view>
          </view>

          <view class="item-row">
            <text class="label">冻结时间</text>
            <text class="value">{{ item.frozenTime }}</text>
          </view>

          <view class="item-row">
            <text class="label">预计解冻时间</text>
            <text class="value">{{ item.unfreezeTime }}</text>
          </view>

          <view class="item-row">
            <text class="label">冻结原因</text>
            <text class="value reason">{{ item.reason }}</text>
          </view>
        </view>

        <!-- 空状态 -->
        <view v-if="frozenList.length === 0" class="empty-state">
          <image
            src="/static/logo.png"
            class="empty-image"
            mode="aspectFit"
          ></image>
          <text class="empty-text">暂无数据~</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";

// 搜索关键词
const searchKeyword = ref("");

// 冻结抵用券列表
const frozenList = ref([
  {
    orderNumber: "202510201234567890",
    amount: "50.00",
    frozenTime: "2025-10-20 14:30:25",
    unfreezeTime: "2025-10-27 14:30:25",
    reason: "订单退款中",
  },
  {
    orderNumber: "202510191234567890",
    amount: "30.50",
    frozenTime: "2025-10-19 10:15:30",
    unfreezeTime: "2025-10-26 10:15:30",
    reason: "订单售后处理中",
  },
  {
    orderNumber: "202510181234567890",
    amount: "100.00",
    frozenTime: "2025-10-18 16:45:10",
    unfreezeTime: "2025-10-25 16:45:10",
    reason: "订单退款中",
  },
]);

// 返回
const goBack = () => {
  uni.navigateBack();
};

// 搜索
const handleSearch = () => {
  console.log("搜索关键词:", searchKeyword.value);
  // TODO: 调用接口搜索
};
</script>

<style lang="scss" scoped>
.page-container {
  min-height: 100vh;
  background-color: #f5f5f5;
}

.content {
  padding: 32rpx;
  padding-top: 20rpx;
}

// 搜索框
.search-box {
  margin-bottom: 24rpx;

  :deep(.uni-easyinput) {
    background-color: #fff;
    border-radius: 50rpx;
    overflow: hidden;
  }

  :deep(.uni-easyinput__content) {
    background-color: #fff;
    border-radius: 50rpx;
  }

  :deep(.uni-easyinput__content-input) {
    font-size: 28rpx;
    height: 72rpx;
  }

  .search-btn {
    padding: 0 32rpx;
    height: 72rpx;
    line-height: 72rpx;
    background: linear-gradient(135deg, #ffd000 0%, #ff9500 100%);
    color: #fff;
    font-size: 28rpx;
    border-radius: 0 50rpx 50rpx 0;
    white-space: nowrap;

    &:active {
      opacity: 0.8;
    }
  }
}

// 冻结列表
.frozen-list {
  display: flex;
  flex-direction: column;
  gap: 24rpx;
}

.frozen-item {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 32rpx;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24rpx;
  padding-bottom: 24rpx;
  border-bottom: 1rpx solid #f5f5f5;
}

.order-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}

.order-label {
  font-size: 24rpx;
  color: #999;
}

.order-number {
  font-size: 28rpx;
  color: #333;
  font-weight: 500;
}

.frozen-amount {
  font-size: 36rpx;
  color: #ff2d2d;
  font-weight: 600;
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16rpx 0;

  .label {
    font-size: 28rpx;
    color: #666;
    flex-shrink: 0;
  }

  .value {
    font-size: 28rpx;
    color: #333;
    text-align: right;
    margin-left: 32rpx;

    &.reason {
      color: #ff9500;
      font-weight: 500;
    }
  }
}

// 空状态
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120rpx 0;
}

.empty-image {
  width: 300rpx;
  height: 300rpx;
  margin-bottom: 32rpx;
  opacity: 0.3;
}

.empty-text {
  font-size: 28rpx;
  color: #999;
}
</style>
